package cn.net.isir.dao;

import cn.net.isir.core.BasicDao;
import cn.net.isir.entity.Order;
import cn.net.isir.entity.TimeRange;
import cn.net.isir.entity.Turn;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class TurnDao extends BasicDao<Turn> {

    /**
     * 获取转出信息
     *
     * @param shopId 店铺id
     * @return 列表
     */
    public List<Map<String, Object>> getLastMonthShopTurnInfoByShopId(BigDecimal everyOrderFee, String shopId, List<TimeRange> timeRangeList) {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("shopId", shopId);
        map.put("finalTotal", everyOrderFee);
        map.put("timeRangeList", timeRangeList);
        List<Object> a = sqlSessionTemplate.selectList("getLastMonthShopTurnInfoByShopId", map);
        return sqlSessionTemplate.selectList("getLastMonthShopTurnInfoByShopId", map);
    }

    /**
     * 获取转出订单信息,方便统计
     *
     * @param shopId 店铺id
     * @return 订单列表(最多20条, 因为日活标准是20条)
     */
    public List<Order> getLastMonthTotalFlowByShopId(String shopId, List<TimeRange> timeRangeList) {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("shopId", shopId);
        map.put("timeRangeList", timeRangeList);
        return sqlSessionTemplate.selectList("getLastMonthTotalFlowByShopId", map);
    }
}
